package com.xbongbong.saas.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 应收款/付款计划的统计类型
 * 主要是因为付款计划/应收款需要统计计划付款/回款金额、坏账金额、已收金额
 * Company: 逍邦网络科技有限公司<p>
 *
 * @author chenshan
 * @version v1.0
 * @since 2020-03-14 15:23
 */
@Getter
public enum PlanTotalTypeEnum {
    NORMAL(1, "normal", "统计计划付款/回款金额"),
    BAD_TOTAL(2, "badTotal", "统计坏账金额"),
    FINISH_TOTAL(3, "finishTotal", "统计已收金额");
    private int code;
    private String alias;
    private String name;
    
    PlanTotalTypeEnum(int code, String alias, String name) {
        this.code = code;
        this.alias = alias;
        this.name = name;
    }
    
    
    public static List<PlanTotalTypeEnum> getAllEnum() {
        List<PlanTotalTypeEnum> list = new ArrayList<>();
        for ( PlanTotalTypeEnum cache : values() ) {
            list.add(cache);
        }
        return list;
    }
    
    public static PlanTotalTypeEnum getByAlias(String alias) {
        for ( PlanTotalTypeEnum cacheCode : values() ) {
            if ( cacheCode.getAlias().equals(alias) ) {
                return cacheCode;
            }
        }
        return null;
    }
}
